package models

import (
	"errors"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

type File struct {
	Id        int
	ProjectId int
	UserId    int
	Name      string
	Path      string
	Version   int
}

func init() {
	orm.RegisterModel(new(File))
	orm.RegisterDriver("mysql", orm.DRMySQL)
	orm.RegisterDataBase("default", "mysql", "root:123456@tcp(39.106.40.170:3306)/sys")
	orm.RunSyncdb("default", false, true)
	orm.Debug = true
}

func Register(v File) error {
	o := orm.NewOrm()
	_, err := o.Insert(&v)
	if err != nil {
		return errors.New("添加失败")
	}
	return nil
}
